package edu.gwu.computerarchitecture.operation.execute;

import edu.gwu.computerarchitecture.cpu.CPUUnits;
import edu.gwu.computerarchitecture.entity.WordType;
import edu.gwu.computerarchitecture.operation.Instruction;

/**
 * 
 * implement the execution of LDFR instruction
 *
 * <p>detailed comment
 * @author Erzheng Dai 2013年12月7日
 * @see Execute
 * @since 1.0
 * @version 1.0
 */
public class ExecuteLDFR extends Execute
{
    public ExecuteLDFR(CPUUnits units, Instruction instr)
    {
        super(units, instr);
        // TODO Auto-generated constructor stub
    }
    /**
     * 
     * implement the LDFR
     * 
     * @see edu.gwu.computerarchitecture.operation.execute.Execute#execute()
     */
    public void execute(){
        calculateEA();
        //super.dataToRegister = cpuunits.mdr.getRegister();
        super.instruction.dataToRegisterLow = cpuunits.mdr.getRegister().getWord();
        //Lower Address store in dataToRegisterLow
        cpuunits.mar.setRegister(new WordType(cpuunits.mar.getRegister().getWord()+1));
        cpuunits.mdr.setRegister(new WordType(cpuunits.memory.getMemory(cpuunits.mar.getRegister().getWord())));

        super.instruction.dataToRegister = cpuunits.mdr.getRegister().getWord();
        /*
         * test
         */
        System.out.println("Enter ExecuteLDFR: data" + super.instruction.dataToRegisterLow);
        System.out.println("Enter ExecuteLDFR: data" + super.instruction.dataToRegister);
      //  Register rsr1 = rfRegister(instruction.rsr1);
                   
      //  rsr1.setRegister(cpuunits.mdr.getRegister());
    }
}
